import re

# 写入新的内容会将原本内容删除
f3 = open('data.txt','w',encoding='utf-8')
f3.write('11000 00112 02211\n'
         '4513 dwfa 方法为 2155')
f3.close()

# 添加文本内容
with open('data.txt', 'a+', encoding='utf-8') as f1:
    f1.write('\nwo men 5599 dou you mei hao de ming tian')

# 读出文本内容
with open('data.txt', 'r', encoding='utf-8') as f2:
    line = f2.readlines()
a = ''
for i in line:
    a = a + i

# 输出所有数字
def fib():
    for i in re.findall(r'\d+',a):
        yield i

iter = fib()
for i in iter:
    print(i , end='\t')


# # 思维二：找内容，和下标
# with open('data.txt','r',encoding='utf-8') as f4:
#     lines = f4.readlines()
#     s1 = ','.join(lines)
#
# l1 = re.findall(r'w.*u',s1,re.M)
#
# class FindSter:
#     def __init__(self,fild_str):
#         self.sild_str = fild_str
#         self.i = -1
#
#         def __iter__(self):
#             return self
#
#         def __next__(self):
#             self.i += 1
#             if self.i < len(self.fild_str):
#                 return self.fild_str[self.i]
#             else:
#                 raise StopIteration
#
# for values in FindSter(l1):
#     print(values)